#include "signalmainpage.h"
#include "ui_signalmainpage.h"
#include <QDebug>

SignalMainpage::SignalMainpage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SignalMainpage)
{
    ui->setupUi(this);
    setAutoFillBackground(true);  //设置自动填充
    QPalette palette = BKGCLR;
    setPalette(palette);

    target_distance_bar_ = new ScaleWidget(this);
    target_distance_bar_->setGeometry(20,70,120,400);
    target_distance_bar_->show();

    dashboard_ = new DashBoard2(this);
    dashboard_->setGeometry(150,-10,450,450);

    readATCEMsgInfo("./atcmsginfo.csv");
    InitSound();

    atc_comflt_page_ = new QLabel(this);
    atc_comflt_page_->setGeometry(0,0,1100,481);
    atc_comflt_page_->setStyleSheet("background-color:rgb(0,0,0);color:rgb(255,255,255);font:40pt 'Arial';border:none;");
    atc_comflt_page_->setAlignment(Qt::AlignCenter);
    atc_comflt_page_->setText(QString("        %1\n\n        速度：%2km/h").arg("21:48").arg(0));
    atc_comflt_page_->hide();

    new_message_timer_ = new QTimer(this);
    connect(new_message_timer_,SIGNAL(timeout()),this,SLOT(slot_New_Message()));
    new_message_timer_->setInterval(500);

    atp_eb_success_timer_ = new QTimer(this);
    connect(atp_eb_success_timer_,SIGNAL(timeout()),this,SLOT(slot_timerout()));
    atp_eb_success_timer_->setInterval(GlobalConfig::atp_EB_test_success_delay);

    m3_flash_timer_ = new QTimer(this);
    connect(m3_flash_timer_,SIGNAL(timeout()),this,SLOT(slot_M3_flash()));
    m3_flash_timer_->setInterval(500);

    ui->N->setAlignment(Qt::AlignCenter);

    atc_all_stat_labels_.append(ui->A1);
    atc_all_stat_labels_.append(ui->N);
    atc_all_stat_labels_.append(ui->C1);
    atc_all_stat_labels_.append(ui->C2);
    atc_all_stat_labels_.append(ui->C3);
    atc_all_stat_labels_.append(ui->C4);
    atc_all_stat_labels_.append(ui->C5);
    atc_all_stat_labels_.append(ui->G3_1);
    atc_all_stat_labels_.append(ui->G3_2);
    atc_all_stat_labels_.append(ui->G3_3);
    atc_all_stat_labels_.append(ui->M1);
    atc_all_stat_labels_.append(ui->M2);
    atc_all_stat_labels_.append(ui->M3);
    atc_all_stat_labels_.append(ui->M4);
    atc_all_stat_labels_.append(ui->M5);
    atc_all_stat_labels_.append(ui->M6);
    atc_all_stat_labels_.append(ui->M7);
    atc_all_stat_labels_.append(ui->M8);
    atc_all_stat_labels_.append(ui->M10);
    atc_all_stat_labels_.append(ui->NewMsgBox_E);
    atc_all_stat_labels_.append(ui->NewMsgBox_F);

    atc_pop_menu_ = new SignalPopMenu(this);
    atc_pop_menu_->move((this->width()-atc_pop_menu_->width())/2,(this->height()-atc_pop_menu_->height())/2);
    atc_pop_menu_->hide();
}

SignalMainpage::~SignalMainpage()
{
#ifdef RUN_IN_BOARD
    avic_audioCtrl(0);
#endif
    delete ui;
}
void SignalMainpage::InitSound()
{
#ifdef RUN_IN_BOARD
    myplayinfo info;
    info.samplerate = AUDIO_SAMPLE_RATE_44100;
    info.bitwidth = AUDIO_BIT_WIDTH_16;
    info.soundmode = AUDIO_SOUND_MODE_MONO;
    info.volum = -30;
    info.playmode = 0;
    strcpy(info.filename,"./overspeed.wav");
    HI_Init_Audio(info);
#endif
}

void SignalMainpage::set_Sound_OverSpeed_Stat(uint8_t stat)
{
   signal_5_Sound_overspeed_ = stat;
   try_play_sound();
}

void SignalMainpage::try_play_sound()
{
    if(signal_5_Sound_overspeed_ == 3
       && (signal_0_M1_atp_system_mode_ == 0 || signal_0_M1_atp_system_mode_ == 1))
        Play_ATC_Sound(true);
    else
        Play_ATC_Sound(false);
}

void SignalMainpage::Play_ATC_Sound(bool xPlay)
{
#ifdef RUN_IN_BOARD
    if(avic_get_currentBoardId() != avic_get_mainBoardId())
        return;
    GlobalConfig::addOperationInfo(QString("play over speed sound:%1").arg(xPlay));
    if(!xPlay)
    {
        if(HI_Audio_Get_Playstatus() == 1)
        {
            HI_Audio_Wav_Stop();
            avic_audioCtrl(0);
        }
        return;
    }
    avic_audioCtrl(1);
    HI_Audio_Set_Playmode(1);
    myplayinfo atcmediainfo;
    atcmediainfo.samplerate = AUDIO_SAMPLE_RATE_16000;
    atcmediainfo.bitwidth = AUDIO_BIT_WIDTH_16;
    atcmediainfo.soundmode = AUDIO_SOUND_MODE_MONO;
    atcmediainfo.volum = -50;
    atcmediainfo.playmode = 1;
    strcpy(atcmediainfo.filename,"./overspeed.wav");
    HI_Audio_Wav_Play(atcmediainfo);
#endif
}

void SignalMainpage::enterStandByMode(bool set_mode)
{
    dashboard_->setStandByMode(set_mode);
    target_distance_bar_->setStandByMode(set_mode);
    for(int i=0;i<atc_all_stat_labels_.length();i++)
    {
        atc_all_stat_labels_[i]->setVisible(!set_mode);
    }
}

void SignalMainpage::Set_ATC_ComFlt_Page(bool xcomflt)
{
    atc_comflt_page_->setVisible(xcomflt);
}

void SignalMainpage::flush_ATC_ComFlt_Info(bool atpfs,int speed)
{
    QString info;
    QString current_time = QTime::currentTime().toString("hh:mm");
    if(atpfs)
        info = QString("        ATP 切除\n\n       %1\n\n        速度：%2km/h").arg(current_time).arg(speed);
    else
        info = QString("        %1\n\n        速度：%2km/h").arg(current_time).arg(speed);
    atc_comflt_page_->setText(info);
}

//M5
void SignalMainpage::set_M5_DoorStat(uint8_t stat)
{
    signal_1_M5_door_stat_ = stat;
    set_M5_Stat(signal_1_M5_door_stat_,signal_9_M5_door_mode_,signal_16_M5_door_force_permit_);
}

void SignalMainpage::set_M5_DoorOpenPermitMode(uint8_t mode)
{
    signal_9_M5_door_mode_ = mode;
    set_M5_Stat(signal_1_M5_door_stat_,signal_9_M5_door_mode_,signal_16_M5_door_force_permit_);
}

void SignalMainpage::set_M5_DoorForcePermit(uint8_t cmd)
{
    signal_16_M5_door_force_permit_ = cmd;
    set_M5_Stat(signal_1_M5_door_stat_,signal_9_M5_door_mode_,signal_16_M5_door_force_permit_);
}

void SignalMainpage::set_M5_Stat(uint8_t door_stat,uint8_t door_mode,uint8_t force_permit_cmd)
{
    if(door_mode ==0 && door_stat == 0)//
        ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5NoCmdDoorOpen.png);");
    else if(door_stat == 0)
        ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5LROpenCmdDoorOpen.png);");
    else if(door_stat == 1)
        ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5ROpenCmdDoorOpen.png);");
    else if(door_stat == 2)
        ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5LOpenCmdDoorOpen.png);");
    else if(door_stat == 3)
    {
        if(door_mode == 0)
            ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5NoCmdDoorClose.png);");
        else if(door_mode == 1)
            ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5OnlyLDoorOpen.png);");
        else if(door_mode == 2)
            ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5OnlyRDoorOpen.png);");
        else if(door_mode == 5)
            ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5LROpenCmdDoorClose.png);");
    }
    else if(door_stat == 12)
        ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5LROpenCmdDoorOpen.png);");
    else if(force_permit_cmd == 1)
        ui->M5->setStyleSheet("border-image: url(:/Images/SIGNAL/M5PsdForceEnable-unuse.png);");
}
//M1
void SignalMainpage::set_M1_Stat(uint8_t atp_system_mode)
{
    signal_0_M1_atp_system_mode_ = atp_system_mode;
    bool standby_mode = false;
    switch (atp_system_mode) {
    case 0:
        ui->M1->setStyleSheet("border-image: url(:/Images/SIGNAL/M1Rm.png);");
        break;
    case 1:
        ui->M1->setStyleSheet("border-image: url(:/Images/SIGNAL/M1Cm.png);");
        break;
    case 2:
        ui->M1->setStyleSheet("border-image: url(:/Images/SIGNAL/M1Am.png);");
        break;
    case 3:
        ui->M1->setStyleSheet("border-image: url(:/Images/SIGNAL/M1Eum.png);");
        break;
    case 4:
        standby_mode = true;
        break;
    case 6:
        ui->M1->setStyleSheet("border-image: url(:/Images/SIGNAL/M1Cam.png);");
        break;
    case 8:
        ui->M1->setStyleSheet("border-image: url(:/Images/SIGNAL/M1Fam.png);");
        break;
    case 10:
        ui->M1->setStyleSheet("border-image: url(:/Images/SIGNAL/M1Rrm.png);");
        break;
    }
    set_M2_Stat(signal_0_M1_atp_system_mode_,signal_15_M2_current_run_level_);
    setRecSpeed(signal_0_M1_atp_system_mode_,signal_47_rec_speed_);
    set_A1_Stat(signal_28_A1_EB_,signal_0_M1_atp_system_mode_,signal_45_train_speed_,signal_47_rec_speed_);
    set_M7_Stat(signal_0_M1_atp_system_mode_,signal_55_M7_door_control_mode_);
    set_M6_stat(signal_0_M1_atp_system_mode_,signal_56_M6_depart_hint_,signal_62_M6_door_close_hint_);
    set_C1_Stat(signal_0_M1_atp_system_mode_,signal_60_C1_ATO_trac_brk_stat_);
    set_N_stat(signal_0_M1_atp_system_mode_,
               signal_59_N_go_indication_,
               signal_61_N_no_go_indication_,
               signal_58_N_clear_passengers_,
               signal_91_N_DTI_time_count_type_,
               signal_92_N_DTI_time_count_);
    updateTargetDistanceStat(signal_0_M1_atp_system_mode_,signal_44_target_distance_);
    enterStandByMode(standby_mode);
    try_play_sound();
}
//M8
void SignalMainpage::set_M8_RightPSDStat(uint8_t stat)
{
    signal_2_M8_right_PSD_stat_ = stat;
    set_M8_Stat(signal_2_M8_right_PSD_stat_,
                signal_3_M8_left_PSD_stat_,
                signal_11_M8_idling_slip_,
                signal_28_A1_EB_);
}

void SignalMainpage::set_M8_LeftPSDStat(uint8_t stat)
{
    signal_3_M8_left_PSD_stat_ = stat;
    set_M8_Stat(signal_2_M8_right_PSD_stat_,
                signal_3_M8_left_PSD_stat_,
                signal_11_M8_idling_slip_,
                signal_28_A1_EB_);
}

void SignalMainpage::set_M8_IdlingSlipStat(uint8_t stat)
{
    signal_11_M8_idling_slip_ = stat;
    set_M8_Stat(signal_2_M8_right_PSD_stat_,
                signal_3_M8_left_PSD_stat_,
                signal_11_M8_idling_slip_,
                signal_28_A1_EB_);
}

void SignalMainpage::set_M8_EBStat(uint8_t stat)
{
    signal_28_A1_EB_ = stat;
    set_M8_Stat(signal_2_M8_right_PSD_stat_,
                signal_3_M8_left_PSD_stat_,
                signal_11_M8_idling_slip_,
                signal_28_A1_EB_);
    set_A1_Stat(signal_28_A1_EB_,signal_0_M1_atp_system_mode_,signal_45_train_speed_,signal_47_rec_speed_);
}

void SignalMainpage::set_M8_Stat(uint8_t rpsd_stat,uint8_t lpsd_stat,uint8_t idling_slip,uint8_t eb)
{
    if(eb == 0)
        ui->M8->setStyleSheet("border-image: url(:/Images/SIGNAL/M8TrainEb.png);");
    else if(rpsd_stat == 0 || lpsd_stat == 0)
        ui->M8->setStyleSheet("border-image: url(:/Images/SIGNAL/M8PsdOpen.png);");
    else if(idling_slip == 1 || idling_slip == 2)
        ui->M8->setStyleSheet("border-image: url(:/Images/SIGNAL/C1WheelSlip.png);");
    else
        ui->M8->setStyleSheet("background-color:rgb(0,0,0);");
}
//A1
void SignalMainpage::set_A1_Stat(uint8_t eb_stat, uint8_t mode, uint8_t speed, uint8_t rec_speed)
{
    if(eb_stat == 0)
        ui->A1->setStyleSheet("background-color:rgb(255,0,0);");
    else if(mode != 0 && mode != 1)
        ui->A1->setStyleSheet("background-color:rgb(0,0,0);");
    else if(speed > rec_speed)
        ui->A1->setStyleSheet("background-color:rgb(255, 127, 64);");
    else
        ui->A1->setStyleSheet("background-color:rgb(0,0,0);");
}
//M10
void SignalMainpage::set_M10_LocationStat(uint8_t stat)
{
    signal_4_M10_islocated_ = stat;
    set_M10_Stat(signal_4_M10_islocated_,signal_14_M10_depot_,signal_21_M10_train_fire_,signal_20_M10_release_speed_);
}

void SignalMainpage::set_M10_DepotStat(uint8_t stat)
{
    signal_14_M10_depot_ = stat;
    set_M10_Stat(signal_4_M10_islocated_,signal_14_M10_depot_,signal_21_M10_train_fire_,signal_20_M10_release_speed_);
}

void SignalMainpage::set_M10_TrainFireStat(bool stat)
{
    signal_21_M10_train_fire_ = stat;
    set_M10_Stat(signal_4_M10_islocated_,signal_14_M10_depot_,signal_21_M10_train_fire_,signal_20_M10_release_speed_);
}

void SignalMainpage::set_M10_ReleaseSpeedStat(bool stat)
{
    signal_20_M10_release_speed_ = stat;
    update_F_Text();
    set_M10_Stat(signal_4_M10_islocated_,signal_14_M10_depot_,signal_21_M10_train_fire_,signal_20_M10_release_speed_);
}

void SignalMainpage::set_M10_Stat(uint8_t is_located, uint8_t depot_stat, bool fire, bool release_speed)
{
    if(depot_stat == 1)
        ui->M10->setStyleSheet("border-image: url(:/Images/SIGNAL/M10EnterDepot.png);");
    else if(is_located == 0 || depot_stat == 2)
        ui->M10->setStyleSheet("border-image: url(:/Images/SIGNAL/M10RunInDepot.png);");
    else if(depot_stat == 3)
        ui->M10->setStyleSheet("border-image: url(:/Images/SIGNAL/M10EnterGarage.png);");
    else if(release_speed)
        ui->M10->setStyleSheet("border-image: url(:/Images/SIGNAL/M10ReleaseSpeed.png);");
    else if(fire)
        ui->M10->setStyleSheet("border-image: url(:/Images/SIGNAL/M10Fire.png);");
    else
        ui->M10->setStyleSheet("background-color:rgb(0,0,0);");
}
//F
void SignalMainpage::slot_New_Message()
{
    static bool m_xNewMsgFlash = false;
    if(!m_xNewMsgFlash)
        ui->NewMsgBox_F->setStyleSheet("background-color:rgb(0,0,0);"
                                       "border:2px solid rgb(252, 248, 61);"
                                       "color:rgb(255,255,255);"
                                       "font:15pt 'Arial';");
    else
        ui->NewMsgBox_F->setStyleSheet("background-color:rgb(0,0,0);"
                                       "color:rgb(255,255,255);"
                                       "font:15pt 'Arial';"
                                       "border:2px solid rgb(0,0,0);");
    m_xNewMsgFlash = !m_xNewMsgFlash;
}

void SignalMainpage::set_F_Message_Text(bool xtrigger, const QString &text)
{
    if(xtrigger)
    {
        ui->NewMsgBox_F->setText(text);
        ui->NewMsgBox_F->setStyleSheet("background-color:rgb(0,0,0);"
                                       "border:2px solid rgb(252, 248, 61);"
                                       "color:rgb(255,255,255);"
                                       "font:15pt 'Arial';");
        new_message_timer_->start();
    }
    else
    {
        ui->NewMsgBox_F->setText("");
        new_message_timer_->stop();
        ui->NewMsgBox_F->setStyleSheet("background-color:rgb(0,0,0);"
                                       "color:rgb(255,255,255);"
                                       "font:15pt 'Arial';"
                                       "border:2px solid rgb(0,0,0);");
    }
}

void SignalMainpage::slot_timerout()
{
    set_F_Message_Text(false,"");
}

void SignalMainpage::update_F_Text()
{
    QString text_showed_in_F;
    int need_show_in_F = decide_need_show_text_F(text_showed_in_F);
    qDebug()<<"need show:"<<need_show_in_F<<" text:"<<text_showed_in_F;
    if(need_show_in_F == 1 && text_showed_in_F != "紧急制动测试成功！")
        atp_eb_success_timer_->stop();
    set_F_Message_Text(need_show_in_F,text_showed_in_F);
}
//0-not show 1-show 3-invalid
int SignalMainpage::decide_need_show_text_F(QString &show_text)
{
//------------------ 1 ----------------------
    if(signal_78_F_local_sleep_ == 1)
    {
        show_text = QString("列车准备休眠，请关闭钥匙！");
        return 1;
    }
    //qDebug()<<"1 通过";
//------------------ 2 ----------------------
    if(signal_77_F_runtime_toolong_ == 1)
    {
        show_text = QString("运行超时，将在停车后实施自关断！");
        return 1;
    }
    //qDebug()<<"2 通过";
//------------------ 3 ----------------------
    if(signal_76_F_unlock_door_)
    {
        show_text = QString("车门紧急解锁手柄拉下！");
        return 1;
    }
    //qDebug()<<"3 通过";
//------------------ 4 ----------------------
    if(signal_75_F_escape_door_open_)
    {
        show_text = QString("逃生门紧急手柄已拉下！");
        return 1;
    }
    //qDebug()<<"4 通过";
//------------------ 5 ----------------------
    if(signal_84_F_upgrade_FAM_ == 1)
    {
        show_text = QString("确认升级FAM,请将方向手柄置中间位! ");
        return 1;
    }
    else if(signal_84_F_upgrade_FAM_ == 2)
    {
        show_text = QString("请确认转为FAM模式运行！");
        return 1;
    }
    else if(signal_84_F_upgrade_FAM_ == 3)
    {
        show_text = QString("请关闭钥匙升级为FAM模式！");
        return 1;
    }
    //qDebug()<<"5 通过";
//------------------ 6 ----------------------
    if(signal_83_F_quit_FAM_ == 1)
    {
        show_text = QString("请打开钥匙，退出FAM/CAM模式！");
        return 1;
    }
    //qDebug()<<"6 通过";
//------------------ 7 ----------------------
    if(signal_82_F_sleep_failed_ == 1)
    {
        show_text = QString("休眠失败！");
        return 1;
    }
    //qDebug()<<"7 通过";
//------------------ 8 ----------------------
    if(signal_79_F_wakeup_feedback_ == 1)
    {
        show_text = QString("唤醒成功！");
        return 1;
    }
    else if(signal_79_F_wakeup_feedback_ == 2)
    {
        show_text = QString("唤醒失败！");
        return 1;
    }
    //qDebug()<<"8 通过";
//------------------ 9 ----------------------
    if(signal_88_F_temporary_speed_limit_)
    {
        show_text = QString("前方有临时限速！");
        return 1;
    }
    //qDebug()<<"9 通过";
//------------------ 10 ---------------------
    if(signal_81_F_passenger_pull_em_handle_)
    {
        show_text = QString("乘客紧急手柄拉下！");
        return 1;
    }
    //qDebug()<<"10 通过";
//------------------ 11 ---------------------
    if(signal_80_F_wheel_calibration_failed_)
    {
        show_text = QString("轮径校正失败！");
        return 1;
    }
    //qDebug()<<"11 通过";
//------------------ 12 ---------------------
    if(signal_89_F_backward_select_ == 1 && signal_90_F_forward_select_ == 1)
    {
        show_text = QString("请确认前方和后方是否满足筛选！");
        return 1;
    }
    else if(signal_89_F_backward_select_ == 2 && signal_90_F_forward_select_ == 2)
    {
        show_text = QString("前方和后方区域满足筛选确认！");
        return 1;
    }
    //qDebug()<<"12 通过";
//------------------ 13 ---------------------
    if(signal_73_F_EB_test_ != 0)
    {
        if(signal_73_F_EB_test_ == 0xF2)
        {
            show_text = QString("请手动进行紧急测试！");
            return 1;
        }
        else if(signal_73_F_EB_test_ == 0xF0)
        {
            show_text = QString("紧急测试失败！请再次测试");
            return 1;
        }
        else if(pre_73_F_EB_test_ != 0xF1 && signal_73_F_EB_test_ == 0xF1)
        {
            show_text = QString("紧急制动测试成功！");
            atp_eb_success_timer_->start();
            return 1;
        }
        else if(signal_73_F_EB_test_ == 0x01)
        {
            show_text = QString("紧急制动1施加2缓解");
            return 1;
        }
        else if(signal_73_F_EB_test_ == 0x02)
        {
            show_text = QString("紧急制动1缓解2施加");
            return 1;
        }
        else if(signal_73_F_EB_test_ == 0x03)
        {
            show_text = QString("紧急制动1施加2施加");
            return 1;
        }
        else if(signal_73_F_EB_test_ == 0x04)
        {
            show_text = QString("紧急制动1缓解2缓解");
            return 1;
        }
    }
    else
    {
        if(signal_74_F_EB_test_fail_code_ == 0x11)
        {
            show_text = QString("车辆未停稳，无法EB测试！");
            return 1;
        }
        else if(signal_74_F_EB_test_fail_code_ == 0x22)
        {
            show_text = QString("非RM模式，无法EB测试！");
            return 1;
        }
        else if(signal_74_F_EB_test_fail_code_ == 0x33)
        {
            show_text = QString("处于紧急状态，无法EB测试！");
            return 1;
        }
        else if(signal_74_F_EB_test_fail_code_ == 0x44)
        {
            show_text = QString("列车外部紧急，无法EB测试！");
            return 1;
        }
        else if(signal_74_F_EB_test_fail_code_ == 0x55)
        {
            show_text = QString("紧急制动测试中，无法响应！");
            return 1;
        }
        else if(signal_74_F_EB_test_fail_code_ != 0)
        {
            show_text = QString("条件不满足，无法EB测试！");
            return 1;
        }
    }
    //qDebug()<<"13 通过";
//------------------ 14 ---------------------
    if(signal_69_F_train_number_error_  ==  0xAA)
    {
        uint8_t car_number_ = (signal_68_F_local_train_number_ & 0x00001FFC) >> 2;
        uint8_t group_number_ = (signal_68_F_local_train_number_ & 0x00000003);

        if((signal_70_F_VID_error_code_&0x01) == 0x01)
        {
           show_text = QString("VID校验通过！");
           return 1;
        }
        else if((signal_70_F_VID_error_code_&0x02) == 0x02)
        {
           show_text = QString("双系比较VID不一致! ");
           return 1;
        }
        else if((signal_70_F_VID_error_code_&0x04) == 0x04)
        {
           show_text = QString("与本端ATO比较不一致！");
           return 1;
        }
        else if((signal_70_F_VID_error_code_&0x08) == 0x08)
        {
           show_text = QString("VID与对端ATP比较不一致！");
           return 1;
        }
        else if((signal_70_F_VID_error_code_&0x10) == 0x10)
        {
           show_text = QString("本端VID取值不合法！");
           return 1;
        }
        else if((signal_70_F_VID_error_code_&0x40) == 0x40)
        {
           show_text = QString("尾端VID校验不一致！");
           return 1;
        }
        else if((signal_70_F_VID_error_code_&0x20) == 0x20)
        {
           show_text = QString("无ATO的VID!请确认本端为%1车%2端").arg(car_number_).arg(group_number_);
           return 1;
        }
        else if((signal_70_F_VID_error_code_&0x80) == 0x80)
        {
            show_text = QString("首尾通信故障!请确认本端为%1车%2端").arg(car_number_).arg(group_number_);
            return 1;
        }
    }
    //qDebug()<<"14 通过";
//------------------ 15 ---------------------
    if(signal_30_F_hint_rain_snow_)
    {
       show_text = QString("请确认进入雨雪模式！");
       return 1;
    }
    //qDebug()<<"15 通过";
//------------------ 16 ---------------------
    if(signal_7_F_is_preselecting_ == 1)
    {
       show_text = QString("请确认模式/级别的预选择！");
       return 1;
    }
    //qDebug()<<"16 通过";
//------------------ 18 ---------------------
    if(signal_23_F_confirm_RM_ == 1)
    {
       show_text = QString("请确认以RM模式行车！");
       return 1;
    }
    //qDebug()<<"18 通过";
//------------------ 19 ---------------------
    if(signal_22_F_speed_release_ == 1)
    {
       show_text = QString("确认前方信号开放，以低速接近！");
       return 1;
    }
    //qDebug()<<"19 通过";
//------------------ 20 ---------------------
    if(signal_13_F_back_to_depot_hint_ == 1)
    {
        show_text = QString("请确认以RM模式回段！");
        return 1;
    }
    else if(signal_13_F_back_to_depot_hint_ == 2)
    {
        show_text = QString("请确认以RM模式回库！");
        return 1;
    }
    //qDebug()<<"20 通过";
//------------------ 21 ---------------------
    if(signal_20_M10_release_speed_)
    {
        show_text = QString("开口速度激活！");
        return 1;
    }
    //qDebug()<<"21 通过";

    return 0;
}

void SignalMainpage::set_F_PreSelectStat(uint8_t stat)
{
    signal_7_F_is_preselecting_ = stat;
    update_F_Text();
}

void SignalMainpage::set_F_BackToDepotHint(uint8_t hint)
{
    signal_13_F_back_to_depot_hint_ = hint;
    update_F_Text();
}

void SignalMainpage::set_F_ConfirmRunInRM(uint8_t mode)
{
    signal_23_F_confirm_RM_ = mode;
    update_F_Text();
}

void SignalMainpage::set_F_SpeedReleaseStat(uint8_t stat)
{
    signal_22_F_speed_release_ = stat;
    update_F_Text();
}

void SignalMainpage::set_F_EnterRainOrSnowMode(bool xhint)
{
    signal_30_F_hint_rain_snow_ = xhint;
    update_F_Text();
}

void SignalMainpage::set_F_LocalTrainNumber(uint32_t number)
{
    signal_68_F_local_train_number_ = number;
    update_F_Text();
}

void SignalMainpage::set_F_TrainNumberErrorIndication(uint8_t indication)
{
    signal_69_F_train_number_error_ = indication;
    update_F_Text();
}

void SignalMainpage::set_F_VIDCheckStat(uint8_t stat)
{
    signal_70_F_VID_error_code_ = stat;
    update_F_Text();
}

void SignalMainpage::set_F_EBTestStat(uint8_t eb_test)
{
    signal_73_F_EB_test_ = eb_test;
    atc_pop_menu_->set_EB_Test_Stat(eb_test);
    update_F_Text();
    pre_73_F_EB_test_ = eb_test;
}

void SignalMainpage::set_F_EBTestFailedCode(uint8_t code)
{
    signal_74_F_EB_test_fail_code_ = code;
    update_F_Text();
}

void SignalMainpage::indicate_F_EscapeDoorOpen(bool xopen)
{
    signal_75_F_escape_door_open_ = xopen;
    update_F_Text();
}

void SignalMainpage::indicate_F_SalDoorUnlocked(bool xunlock)
{
    signal_76_F_unlock_door_ = xunlock;
    update_F_Text();
}

void SignalMainpage::indicate_F_RunTimeTooLong(uint8_t warning)
{
    signal_77_F_runtime_toolong_ = warning;
    update_F_Text();
}

void SignalMainpage::remind_F_DriverTakeOffKey(uint8_t reminder)
{
    signal_78_F_local_sleep_ = reminder;
    update_F_Text();
}

void SignalMainpage::set_F_ATPWakeUpFeedBackStat(uint8_t stat)
{
    signal_79_F_wakeup_feedback_ = stat;
    update_F_Text();
}

void SignalMainpage::indicate_F_WheelCalibrationFail(bool xfail)
{
    signal_80_F_wheel_calibration_failed_ = xfail;
    update_F_Text();
}

void SignalMainpage::set_F_PassengerPullEmergencyHandle(bool xpull)
{
    signal_81_F_passenger_pull_em_handle_ = xpull;
    update_F_Text();
}

void SignalMainpage::set_F_TrainSleepFailed(uint8_t fail)
{
    signal_82_F_sleep_failed_ = fail;
    update_F_Text();
}

void SignalMainpage::indicate_F_QuitFAMMode(uint8_t fail)
{
    signal_83_F_quit_FAM_ = fail;
    update_F_Text();
}

void SignalMainpage::indicate_F_UpGradeToFAMMode(uint8_t fail)
{
    signal_84_F_upgrade_FAM_ = fail;
    update_F_Text();
}

void SignalMainpage::indicate_F_TempSpeedLimit(bool xtrig)
{
    signal_88_F_temporary_speed_limit_ = xtrig;
    update_F_Text();
}

void SignalMainpage::set_F_BackWardSelect(uint8_t stat)
{
    signal_89_F_backward_select_ = stat;
    update_F_Text();
}

void SignalMainpage::set_F_ForWardSelect(uint8_t stat)
{
    signal_90_F_forward_select_ = stat;
    update_F_Text();
}

//超速声音报警
void SignalMainpage::Over_speed_Sound_Tirgger(uint8_t over_speed)
{
    Play_ATC_Sound(over_speed == 3);
}

//C2
void SignalMainpage::set_C2_CurrentPreSelectMode(uint8_t mode)
{
    signal_6_C2_current_preselect_mode_ = mode;
    switch (mode) {
    case 2:
        ui->C2->setStyleSheet("border-image: url(:/Images/SIGNAL/C2Rm.png);");
        break;
    case 3:
        ui->C2->setStyleSheet("border-image: url(:/Images/SIGNAL/C2Cm_I.png);");
        break;
    case 4:
        ui->C2->setStyleSheet("border-image: url(:/Images/SIGNAL/C2Am_I.png);");
        break;
    case 5:
        ui->C2->setStyleSheet("border-image: url(:/Images/SIGNAL/C2Cm_C.png);");
        break;
    case 6:
        ui->C2->setStyleSheet("border-image: url(:/Images/SIGNAL/C2Am_C.png);");
        break;
    case 7:
        ui->C2->setStyleSheet("border-image: url(:/Images/SIGNAL/C2Fam_C.png);");
        break;
    default:
        ui->C2->setStyleSheet("background-color:rgb(0,0,0);");
        break;
    }
}

//M4
void SignalMainpage::set_M4_OutParkAreaStat(uint8_t stat)
{
    signal_10_M4_out_of_park_area_ = stat;
    switch (stat) {
    case 1:
        ui->M4->setStyleSheet("border-image: url(:/Images/SIGNAL/M4NonStopJust.png);");
        break;
    case 2:
        ui->M4->setStyleSheet("border-image: url(:/Images/SIGNAL/M4AllowRetreat.png);");
        break;
    case 3:
        ui->M4->setStyleSheet("border-image: url(:/Images/SIGNAL/M4StopJust.png);");
        break;
    default:
        ui->M4->setStyleSheet("background-color:rgb(0,0,0);");
        break;
    }
}

//M2
void SignalMainpage::set_M2_CurrentRunLevel(uint8_t level)
{
    signal_15_M2_current_run_level_ = level;
    set_M2_Stat(signal_0_M1_atp_system_mode_,signal_15_M2_current_run_level_);
}

void SignalMainpage::set_M2_Stat(uint8_t mode,uint8_t level)
{
    if(mode == 0)
        ui->M2->setStyleSheet("border-image: url(:/Images/SIGNAL/M2ILC.png);");
    else if(level == 1)
        ui->M2->setStyleSheet("border-image: url(:/Images/SIGNAL/M2CTC.png);");
    else if(level == 0)
        ui->M2->setStyleSheet("border-image: url(:/Images/SIGNAL/M2ITC.png);");
}

//C4
void SignalMainpage::set_C4_CutOffTractionStat(uint8_t stat)
{
    signal_25_C4_cutoff_traction_ = stat;
    set_C4_Stat(signal_25_C4_cutoff_traction_,
                signal_26_C4_lack_of_brake_effort_,
                signal_27_C4_rain_and_snow_);
}

void SignalMainpage::set_C4_LackOfBrkEffortStat(bool stat)
{
    signal_26_C4_lack_of_brake_effort_ = stat;
    set_C4_Stat(signal_25_C4_cutoff_traction_,
                signal_26_C4_lack_of_brake_effort_,
                signal_27_C4_rain_and_snow_);
}

void SignalMainpage::set_C4_RainAndSnowStat(bool stat)
{
    signal_27_C4_rain_and_snow_ = stat;
    set_C4_Stat(signal_25_C4_cutoff_traction_,
                signal_26_C4_lack_of_brake_effort_,
                signal_27_C4_rain_and_snow_);
}

void SignalMainpage::set_C4_Stat(uint8_t cut_traciton, bool low_brk_effort, bool rain_snow)
{
    if(low_brk_effort)
        ui->C4->setStyleSheet("border-image: url(:/Images/SIGNAL/C4BrakeUnhealthy.png);");
    else if(cut_traciton == 0)
        ui->C4->setStyleSheet("border-image: url(:/Images/SIGNAL/C4CutMotor.png);");
    else if(rain_snow)
        ui->C4->setStyleSheet("border-image: url(:/Images/SIGNAL/C4RainAndSnowMode.png);");
    else
        ui->C4->setStyleSheet("background-color: rgb(0, 0, 0);");
}

//C3
void SignalMainpage::set_C3_TrainIntegrityStat(uint8_t stat)
{
    signal_31_C3_train_integrity_ = stat;
    if(stat == 0)
        ui->C3->setStyleSheet("border-image: url(:/Images/SIGNAL/C3Intergrity.png);");
    else if(stat == 12)
        ui->C3->setStyleSheet("border-image: url(:/Images/SIGNAL/C3NonIntergrity.png);");
}

//G3
void SignalMainpage::set_G3_ZCConnectionStat(uint8_t stat)
{
    signal_33_G3_ZC_connection_ = stat;
    ui->G3_1->setText("ZC");
    switch (stat) {
    case 0:case 3:case 4:
        ui->G3_1->setStyleSheet("color:rgb(204,204,204);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    case 1:
        ui->G3_1->setStyleSheet("color:rgb(255,255,0);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    case 2:
        ui->G3_1->setStyleSheet("color:rgb(41,146,49);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    default:
        ui->G3_1->setStyleSheet("color:rgb(204,204,204);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    }
}

void SignalMainpage::set_G3_CIConnectionStat(uint8_t stat)
{
    signal_34_G3_CI_connection_ = stat;
    ui->G3_2->setText("CI");
    switch (stat) {
    case 0:case 3:case 4:
        ui->G3_2->setStyleSheet("color:rgb(204,204,204);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    case 1:
        ui->G3_2->setStyleSheet("color:rgb(255,255,0);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    case 2:
        ui->G3_2->setStyleSheet("color:rgb(41,146,49);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    default:
        ui->G3_2->setStyleSheet("color:rgb(204,204,204);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    }
}

void SignalMainpage::set_G3_ATSConnectionStat(uint8_t stat)
{
    signal_35_G3_ATS_connection_ = stat;
    ui->G3_3->setText("ATS");
    switch (stat) {
    case 0:case 3:case 4:
        ui->G3_3->setStyleSheet("color:rgb(204,204,204);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    case 1:
        ui->G3_3->setStyleSheet("color:rgb(255,255,0);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    case 2:
        ui->G3_3->setStyleSheet("color:rgb(41,146,49);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    default:
        ui->G3_3->setStyleSheet("color:rgb(204,204,204);font:22pt 'Arial';background-color: rgb(0, 0, 0);");
        break;
    }
}

//C5
void SignalMainpage::set_C5_ATCDeviceStat(uint8_t stat)
{
    signal_37_C5_ATC_device_stat_ = stat;
    switch (stat) {
    case 1:
        ui->C5->setStyleSheet("border-image: url(:/Images/SIGNAL/C5LocalOkAnothterSTB.png);");
        break;
    case 2:
        ui->C5->setStyleSheet("border-image: url(:/Images/SIGNAL/C5LocalOkAnothterFault.png);");
        break;
    case 3:
        ui->C5->setStyleSheet("border-image: url(:/Images/SIGNAL/C5LocalFaultAnothterOk.png);");
        break;
    default:
        ui->C5->setStyleSheet("background-color: rgb(0, 0, 0);");
        break;
    }
}

//M9
void SignalMainpage::set_M9_ATCSystemFltStat(uint8_t stat)
{
    signal_39_M9_ATC_systemflt_ = stat;
    if((stat & 0x01) == 0x01)
        ui->M9->setStyleSheet("border-image: url(:/Images/SIGNAL/M9AtpFault.png);");
    else if((stat & 0x80) == 0x80)
        ui->M9->setStyleSheet("border-image: url(:/Images/SIGNAL/M9RadioFault.png);");
    else if((stat & 0x08)== 0x08)
        ui->M9->setStyleSheet("border-image: url(:/Images/SIGNAL/M9AtoFault.png);");
    else if((stat & 0x40) == 0x40)
        ui->M9->setStyleSheet("border-image: url(:/Images/SIGNAL/M9AMFault.png);");
    else if((stat & 0x20) == 0x20)
        ui->M9->setStyleSheet("border-image: url(:/Images/SIGNAL/M9AomFault.png);");
    else if((stat & 0x10)== 0x10)
        ui->M9->setStyleSheet("border-image: url(:/Images/SIGNAL/ATP_BTM_FAULT.png);");
    else if((stat & 0x04) == 0x04)
        ui->M9->setStyleSheet("border-image: url(:/Images/SIGNAL/M9TmsFault.png);");
    else
        ui->M9->setStyleSheet("background-color: rgb(0, 0, 0);");
}

//柱状图
void SignalMainpage::setTargetDistance(uint16_t distance)
{
    signal_44_target_distance_ = distance;
    updateTargetDistanceStat(signal_0_M1_atp_system_mode_,signal_44_target_distance_);
}

void SignalMainpage::updateTargetDistanceStat(uint8_t atc_system_mode,uint16_t distance)
{
    if(atc_system_mode == 0)
        target_distance_bar_->setTargetDistance(0);
    else
        target_distance_bar_->setTargetDistance(distance);
}

void SignalMainpage::setTargetSpeed(uint8_t speed)
{
    signal_43_target_speed_ = speed;
    updateTargetSpeedStat(signal_0_M1_atp_system_mode_,signal_43_target_speed_);
}

void SignalMainpage::updateTargetSpeedStat(uint8_t atc_system_mode,uint16_t speed)
{
    if(atc_system_mode == 0)
        target_distance_bar_->setTargetSpeed(0);
    else
        target_distance_bar_->setTargetSpeed(speed);
}

//表盘
void SignalMainpage::setRestritSpeed(uint8_t restrit_speed)
{
    signal_46_restrict_speed_ = restrit_speed;
    dashboard_->setEBSpeed(true,restrit_speed);
}

void SignalMainpage::setRecSpeedvalue(uint8_t rec_speed)
{
    signal_47_rec_speed_ = rec_speed;
    setRecSpeed(signal_0_M1_atp_system_mode_,
                signal_47_rec_speed_);
    set_A1_Stat(signal_28_A1_EB_,signal_0_M1_atp_system_mode_,signal_45_train_speed_,signal_47_rec_speed_);
}

void SignalMainpage::setRecSpeed(uint8_t mode,uint8_t rec_speed)
{
    bool rec_speed_cursor_visible = (mode == 0 || mode == 1);
    dashboard_->setRecSpeed(rec_speed_cursor_visible,rec_speed);
}

void SignalMainpage::setTrainSpeed(uint8_t speed)
{
    signal_45_train_speed_ = speed;
    dashboard_->setRealTimeSpeed(speed);
    set_A1_Stat(signal_28_A1_EB_,signal_0_M1_atp_system_mode_,signal_45_train_speed_,signal_47_rec_speed_);
}

//M6
void SignalMainpage::set_M6_DepartHintStat(uint8_t stat)
{
    signal_56_M6_depart_hint_ = stat;
    set_M6_stat(signal_0_M1_atp_system_mode_,signal_56_M6_depart_hint_,signal_62_M6_door_close_hint_);
}

void SignalMainpage::set_M6_DoorCloseHintStat(uint8_t stat)
{
    signal_62_M6_door_close_hint_ = stat;
    set_M6_stat(signal_0_M1_atp_system_mode_,signal_56_M6_depart_hint_,signal_62_M6_door_close_hint_);
}

void SignalMainpage::set_M6_stat(uint8_t atc_system_mode,uint8_t depart_hint,uint8_t door_close_hint)
{
    if(atc_system_mode == 0)
        ui->M6->setStyleSheet("background-color: rgb(0, 0, 0);");
    else
    {
        if(depart_hint == 3)
            ui->M6->setStyleSheet("border-image: url(:/Images/SIGNAL/M6GoInd.png);");
        else if(door_close_hint == 3)
            ui->M6->setStyleSheet("border-image: url(:/Images/SIGNAL/M6CloseDoor.png);");
        else
            ui->M6->setStyleSheet("background-color: rgb(0, 0, 0);");
    }
}

//M7
void SignalMainpage::set_M7_DoorControlMode(uint8_t mode)
{
    signal_55_M7_door_control_mode_ = mode;
    set_M7_Stat(signal_0_M1_atp_system_mode_,signal_55_M7_door_control_mode_);
}

void SignalMainpage::set_M7_Stat(uint8_t atc_system_mode,uint8_t door_ctrl_mode)
{
    if(atc_system_mode == 0)
        ui->M7->setStyleSheet("background-color: rgb(0, 0, 0);");
    else
    {
        if(door_ctrl_mode == 0)
            ui->M7->setStyleSheet("border-image: url(:/Images/SIGNAL/M7Mm.png);");
        else if(door_ctrl_mode == 1)
            ui->M7->setStyleSheet("border-image: url(:/Images/SIGNAL/M7Am.png);");
        else if(door_ctrl_mode == 2)
            ui->M7->setStyleSheet("border-image: url(:/Images/SIGNAL/M7Aa.png);");
    }
}

//C1
void SignalMainpage::set_C1_ATOTracBrkStat(uint8_t stat)
{
    signal_60_C1_ATO_trac_brk_stat_ = stat;
    set_C1_Stat(signal_0_M1_atp_system_mode_,signal_60_C1_ATO_trac_brk_stat_);
}

void SignalMainpage::set_C1_Stat(uint8_t atc_system_mode,uint8_t trac_brk_stat)
{
    if(atc_system_mode == 0)
        ui->C1->setStyleSheet("background-color: rgb(0, 0, 0);");
    else
    {
        switch (trac_brk_stat) {
        case 1:
            ui->C1->setStyleSheet("border-image: url(:/Images/SIGNAL/C1Motor.png);");
            break;
        case 2:
            ui->C1->setStyleSheet("border-image: url(:/Images/SIGNAL/C1Brake.png);");
            break;
        case 3:
            ui->C1->setStyleSheet("border-image: url(:/Images/SIGNAL/C1Coast.png);");
            break;
        default:
            ui->C1->setStyleSheet("background-color: rgb(0, 0, 0);");
            break;
        }
    }
}
//N
void SignalMainpage::set_N_GoIndicationStat(uint8_t stat)
{
    signal_59_N_go_indication_ = stat;
    set_N_stat(signal_0_M1_atp_system_mode_,
               signal_59_N_go_indication_,
               signal_61_N_no_go_indication_,
               signal_58_N_clear_passengers_,
               signal_91_N_DTI_time_count_type_,
               signal_92_N_DTI_time_count_);
}

void SignalMainpage::set_N_ClearPassengersStat(uint8_t stat)
{
    signal_58_N_clear_passengers_ = stat;
    set_N_stat(signal_0_M1_atp_system_mode_,
               signal_59_N_go_indication_,
               signal_61_N_no_go_indication_,
               signal_58_N_clear_passengers_,
               signal_91_N_DTI_time_count_type_,
               signal_92_N_DTI_time_count_);
}

void SignalMainpage::set_N_NoGoIndicationStat(uint8_t stat)
{
    signal_61_N_no_go_indication_ = stat;
    set_N_stat(signal_0_M1_atp_system_mode_,
               signal_59_N_go_indication_,
               signal_61_N_no_go_indication_,
               signal_58_N_clear_passengers_,
               signal_91_N_DTI_time_count_type_,
               signal_92_N_DTI_time_count_);
}

void SignalMainpage::set_N_DTITimeCountType(uint8_t type)
{
    signal_91_N_DTI_time_count_type_  = type;
    set_N_stat(signal_0_M1_atp_system_mode_,
               signal_59_N_go_indication_,
               signal_61_N_no_go_indication_,
               signal_58_N_clear_passengers_,
               signal_91_N_DTI_time_count_type_,
               signal_92_N_DTI_time_count_);
}
void SignalMainpage::set_N_DTITimeCount(uint16_t count)
{
    signal_92_N_DTI_time_count_ = count;
    set_N_stat(signal_0_M1_atp_system_mode_,
               signal_59_N_go_indication_,
               signal_61_N_no_go_indication_,
               signal_58_N_clear_passengers_,
               signal_91_N_DTI_time_count_type_,
               signal_92_N_DTI_time_count_);
}

void SignalMainpage::set_N_stat(uint8_t atc_system_mode,uint8_t go_ind,uint8_t no_go_ind,uint8_t clear_psg,uint8_t tc_type,uint16_t time_cout)
{ 
    ui->N->setText("");
    if(atc_system_mode == 0)
    {
        ui->N->setStyleSheet("background-color:black;");
        return;
    }

    if(clear_psg == 1)
    {
        ui->N->setStyleSheet("border-image: url(:/Images/SIGNAL/NClear.png);");
        return;
    }
    else
        ui->N->setStyleSheet("background-color:black;");

    if(go_ind == 1)
    {
        ui->N->setStyleSheet("border-image: url(:/Images/SIGNAL/NGoIndication.png);");
        return;
    }
    else
        ui->N->setStyleSheet("background-color:black;");

    if(no_go_ind == 4)
    {
        ui->N->setStyleSheet("border-image: url(:/Images/SIGNAL/NNoGoIndication.png);");
        return;
    }
    else if(no_go_ind == 8)
        ui->N->setStyleSheet("background-color:black;");

    if(tc_type == 0x55)
    {
        ui->N->setStyleSheet("background-color:black;color:red;");
        ui->N->setText(QString("%1").arg(time_cout,3,10,QChar('0')));
    }
    else if(tc_type == 0xaa)
    {
        ui->N->setStyleSheet("background-color:black;color:rgb(41,146,49);");
        ui->N->setText(QString("%1").arg(time_cout,3,10,QChar('0')));
    }
    else if(tc_type == 0xFF)
    {
        ui->N->setStyleSheet("background-color:black;");
        ui->N->setText("");
    }
}

void SignalMainpage::readATCEMsgInfo(QString path)
{
    //ATC消息
    QFile file(path);
    if(file.open(QIODevice::ReadOnly))
    {
        QTextStream stream(&file);
        QString str = stream.readLine(); // title
        while(!stream.atEnd())
        {
            str = stream.readLine();
            QStringList strList = str.split(";");
            if(strList.length() != 2)
                continue;
            hash_code_msg_.insert(strList.at(0).toInt(NULL,16),strList.at(1));
        }
    }
    file.close();
}

void SignalMainpage::setUnReleasedEBStat(bool xtrig)
{
    signal_105_E_unreleased_EB_ = xtrig;
    set_E_Text(signal_105_E_unreleased_EB_,signal_40_E_EB_code_);
}

void SignalMainpage::setEBCode(uint32_t code)
{
    signal_40_E_EB_code_ = code;
    set_E_Text(signal_105_E_unreleased_EB_,signal_40_E_EB_code_);
}

void SignalMainpage::set_E_Text(bool unreleased_eb, uint32_t eb_code)
{
    if(unreleased_eb)
    {
        ui->NewMsgBox_E->setText("发生不可缓解紧急！请重启ATP!");
        return;
    }
    QString text = hash_code_msg_.value(eb_code);
    qDebug()<<"E Text:"<<text;
    ui->NewMsgBox_E->setText(text);
}

void SignalMainpage::set_M3_stat(uint8_t revert_stat)
{
    signal_12_M3_Revert_stat_ = revert_stat;
    if(revert_stat == 1 || revert_stat == 3 || revert_stat == 5)
    {
        ui->M3->setStyleSheet("border-image: url(:/Images/SIGNAL/M3WillAr.png);");
        m3_flash_timer_->start();
    }
    else if(revert_stat == 2 || revert_stat == 4 || revert_stat == 6)
    {
        ui->M3->setStyleSheet("border-image: url(:/Images/SIGNAL/M3ARing.png);");
        m3_flash_timer_->stop();
        ui->M3->show();
    }
    else
    {
        ui->M3->setStyleSheet("background-color: rgb(0, 0, 0);");
        m3_flash_timer_->stop();
        ui->M3->show();
    }
}

void SignalMainpage::slot_M3_flash()
{
    static bool m3_flash_flag = false;
    ui->M3->setVisible(m3_flash_flag);
    m3_flash_flag = !m3_flash_flag;
}

void SignalMainpage::on_Btn_Menu_clicked()
{
    atc_pop_menu_->show();
}

SignalPopMenu* SignalMainpage::Menu() const
{
    return atc_pop_menu_;
}

void SignalMainpage::set_C6_TrainStopDeviation(uint16_t val)
{
    ui->C6->setVisible(val!=0xFFFF);
    signal_107_C6_stop_deviation_ = val;
    ui->C6->setText(QString("%1cm").arg(signal_107_C6_stop_deviation_));
}
